********************************************************************************
*THE CODE APPLIES ROUTINE OPERATIONS TO THE CREDIT REGISTER PROVIDED BY 
*THE BANK OF ITALY, SELECTING START AND END DATE
********************************************************************************
type RO_creditregister.do
args start end strict

noisily display "Set up of the credit register dataset"
rename ente_segn bankid
rename censito_crittog borrowerid
format borrowerid %20.0g
format disbur %20.0g

tostring(time), replace
gen xxx=date(time, "YMD")
drop time
gen time=mofd(xxx)
drop xxx
format time %tm

keep if disbur>=30000|com>=30000
keep if time>=`start'&time<=`end'
drop if comune_dip==.|comune_dip==0

if `strict'==1 {
drop if disbur<30000
}

compress
